import request from '../utils/request.js'

// 获取物资列表
export function getMaterialList(params) {
  return request({
    url: '/selectMaterial/page',
    method: 'get',
    params
  })
}

// 获取物资详情
export function getMaterialDetail(id) {
  return request({
    url: `/getMaterial/${id}`,
    method: 'get'
  })
}

// 捐赠物资
export function donateMaterial(data) {
  return request({
    url: '/insetDonationRecord',
    method: 'post',
    data
  })
}

// 申请物资
export function requestMaterial(data) {
  return request({
    url: '/insetMaterialRequest',
    method: 'post',
    data
  })
}

// 获取物资分类列表
export function getMaterialCategories(params) {
  return request({
    url: '/MaterialType/page',
    method: 'get',
    params
  })
}

// 分页获取申请记录
export function getMaterialRequests(params) {
  return request({
    url: '/selectMaterialRequest/page',
    method: 'get',
    params
  })
}

// 分页获取捐赠记录
export function getMaterialDonations(params) {
  return request({
    url: '/selectDonationRecord/page',
    method: 'get',
    params
  })
}

// 取消物资申请
export function cancelMaterialRequest(id) {
  return request({
    url: `/deleteMaterialRequest/${id}`,
    method: 'delete'
  })
}

// 获取紧缺物资
export function getMaterialShortage() {
  return request({
    url: '/getThreeMaterial',
    method: 'get'
  })
}
